feat(audience): bootstrap wiring, GA/Meta IDs, unload fix#2831
Merged
Conversation
…r, and snippet Add the pixel package scaffold and three self-contained modules that have no dependency on PR #2824. The package builds to a single IIFE bundle (dist/imtbl.js) targeting <10KB gzipped (currently 823 bytes). Modules: - attribution: UTM params, ad click IDs, referrer, landing page (session-cached) - loader: command-queue pattern (window.__imtbl) with pre-load replay - snippet: embeddable <script> tag generator for studio integration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… reference Add dclid (Google DV360) and li_fat_id (LinkedIn) to match the Tracking Pixel Event Reference doc. Also add referral_code parsing and touchpoint_type derivation (set to 'click' when UTMs or click IDs are present). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ion cookie Wire the pixel to audience-core now that PR #2824 has merged: - Consent state machine: three-level (none/anonymous/full), DNT/GPC detection, queue purge on downgrade to none, userId strip on downgrade to anonymous, fire-and-forget PUT to /v1/audience/tracking-consent - Session cookie: _imtbl_sid with 30-min rolling expiry - Pixel class: init creates MessageQueue with storagePrefix isolation, auto-fires PageMessage with attribution context, supports identify at full consent, setConsent, and destroy - Build config: resolves audience-core from source via tsup alias for tree-shaken self-contained IIFE bundle (8.04 KB raw / 3.2 KB gzipped) - Metrics stub: no-op stubs so the pixel bundle doesn't ship internal telemetry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add session lifecycle tracking to the Pixel class: - Fire session_start track event on new session creation - Fire session_end track event on pagehide/visibilitychange with duration - Refactor session module to return SessionResult with isNew flag - Fix test listener leaking by cleaning up pixel instances in afterEach Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move session management, attribution tracking, and consent state machine from @imtbl/pixel into @imtbl/audience-core so the web SDK can share them. - session.ts: use SESSION_COOKIE from core config instead of duplicating - attribution.ts: UTM params, click IDs, referrer, sessionStorage caching - consent.ts: three-level state machine with DNT/GPC, queue purge/transform - Remove pixel re-exports of core modules (no backwards compat needed yet) - Add SESSION_MAX_AGE constant to core config - Pixel now imports everything from @imtbl/audience-core Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Read version from package.json in tsup.config.ts and inject it via esbuild define as PIXEL_VERSION_INJECTED. This stamps every event payload with the correct libraryVersion automatically — no manual bumping needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ering Bootstrap wiring: - Add bootstrap.ts that maps command names to Pixel methods (init, page, identify, consent) and calls createLoader() to install on window.__imtbl with command replay - Add iife.ts as dedicated CDN entry point (excludes snippet generator and createLoader export, saving ~500 bytes) Third-party identity signals: - Read _ga (GA Client ID), _fbc (Meta click ID), _fbp (Meta browser ID) cookies and include in page view properties when present Bug fix: - Register session_end listeners BEFORE queue.start() so that on page unload, session_end is enqueued before the queue's flushUnload fires (DOM listeners fire in registration order) Bundle: 9.23 KB raw / 3.35 KB gzipped Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
View your CI Pipeline Execution ↗ for commit 425e34e
☁️ Nx Cloud last updated this comment at |
6 tasks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nattb8
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the end-to-end pixel by wiring the command-queue loader to the Pixel class and adding third-party identity signals:
bootstrap.ts): Maps command names (init,page,identify,consent) to Pixel methods, installscreateLoader()onwindow.__imtbl, replays any commands the snippet queued before the script loadediife.ts): CDN bundle only imports the bootstrap side-effect — excludes snippet generator andcreateLoaderexport (~500 bytes smaller)_ga(GA Client ID),_fbc(Meta click ID),_fbp(Meta browser ID) cookies and includes them in page view properties when presentsession_endlisteners beforequeue.start()so that on page unload,session_endis enqueued before the queue'sflushUnload()fires (DOM listeners fire in registration order)Bundle: 8.92 KB raw / ~3.4 KB gzipped (well under 10 KB budget)
Test plan
pnpm --filter @imtbl/audience-core test— 87/87 passing (11 suites)pnpm --filter @imtbl/pixel test— 33/33 passing (4 suites)pnpm --filter @imtbl/pixel build— IIFE bundle produced (8.92 KB)pnpm --filter @imtbl/pixel lint— cleanpnpm --filter @imtbl/pixel typecheck— clean🤖 Generated with Claude Code